package com.tanker.web.dto.resp;
import com.google.gson.Gson;
import com.tanker.web.util.Constant;

public class Response{

	private static Gson gson;
	private static Response response;
	private static RespModel respModel;
	private Response(boolean success, String code, String message, Object content) {
		respModel =new RespModel(success,code,message,content);
		gson=new Gson();
	}
	
	public static synchronized String success(Object content) {
		String code =  Constant.ResponseEnum.SUCCESS.getCode();
		String message =  Constant.ResponseEnum.SUCCESS.getMessage();
		if (null == response) {
			response = new Response(true, code,message,content);
		}else{
			respModel.setCode(code);
			respModel.setContent(content);
			respModel.setMessage(message);
			respModel.setSuccess(true);
		}
		return gson.toJson(respModel);
	}
}
